
import Student from "./student.js";

module.exports = class Class{
    constructor(number){
        this.number = number;
    }
    getDisplayName(){
        return `Class ${this.number}`;
    }
    assignLeader(student){
        if(student.klass == this){
            this.leader = student; 
            if(this.teacher){
                console.log(`I am ${this.teacher.name}. I know ${student.name} become Leader of Class ${student.klass.number}.`);                
            }
        }
        else{
            console.log(`It is not one of us.`);
        }
    }
    appendMember(student){
        student.klass = this;
        if(this.teacher){
            console.log(`I am ${this.teacher.name}. I know ${student.name} has joined Class ${student.klass.number}.`);        
        }
    }
    isIn(student){
        if(student.klass = this){
            return true;
        }
        return false;
    }
    registerAssignLeaderListener(teacher){
        this.teacher = teacher;
    }
    registerJoinListener(teacher){
        this.teacher = teacher;
    }
}

